home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48hor1 / iferr.doc < prev    next >
Text File  |  1995-03-31  |  4KB  |  98 lines

  1. (Comp.sys.handhelds) 
  2. Item: 2005 by billw at hpcvra.cv.hp.com. 
  3. Author: [William C Wickes] 
  4.   Subj: Modified HP48 IFERR 
  5.   Date: Fri Feb 08 1991 16:58  
  6.  
  7.                   A New IFERR for HP 48 "Bulletproofing" 
  8.  
  9. Several HP 48 programmers have expressed a concern that the current error 
  10. trapping mechanism via IFERR is vulnerable to repeated ATTN key presses, 
  11. which can prevent a program from cleaning up when it is interrupted by the 
  12. user.  This problem arises because IFERR and all other branching constructs 
  13. built into the HP 48 check to see if ATTN key has been pressed so that 
  14. users cannot (easily) lock themselves into an uninterruptible loop. 
  15.  
  16. The object listed below in ASC-> form is an HP 48 library titled "IF 
  17. ERROR", which provides an alternate version of IFERR/THEN which can be 
  18. uniformly substituted for the built-in versions. The difference between 
  19. this version and that built into the HP 48 is in the handling of ATTN.  The 
  20. ATTN key check is disabled for the THEN clause of the version provided in 
  21. this library, allowing for an "unbreakable" recursive error recovery. 
  22.  
  23. An example of this use is given in the program below. In the "main" 
  24. program, a loop display a counter running from 1 to 1000.  If you press 
  25. ATTN while it is running, the error trap starts another counting loop, this 
  26. time from 1 to 50, to show you that an error termination sequence of some 
  27. length is running.  If you interrupt it, it just restarts itself. 
  28.  
  29. In the first line, the temporary variable 'et' is allocated. This variable 
  30. will hold the error termination procedure after it is created in the next 
  31. part of the program. The error termination procedure is simply a cleanup 
  32. procedure protected by an IFERR which branches back to itself recursively 
  33. if an error occurs in its execution. It is created in a list to avoid the 
  34. inclusion of the opening and closing program quotes, which themselves have 
  35. attention key checks. The remainder of the program is protected by 
  36. IFERR...THEN et EVAL END. 
  37.  
  38. Notes: 
  39.  
  40. * You must access the error termination procedure via a temporary variable 
  41. because global variable execution itself contains an attention key check. 
  42.  
  43. ["temporary variable" = local variable.  -jkh-] 
  44.  
  45. * If your cleanup procedure has an unavoidable error, the only way to stop 
  46. infinite execution is by [ON]-[C]. 
  47.  
  48. * The library (which has ID 1793) is auto-attaching: to use it, all you 
  49. need to do is store it in a port (port 0, say) by putting it on the stack 
  50. and executing 0 STO, and then turning the HP 48 off and on. 
  51.  
  52. * To convert old programs containing IFERR to the new version, you need 
  53. only to EDIT (VISIT), then ENTER when the library is attached. Downloading 
  54. a program in ASCII form via kermit will also automatically use the new 
  55. IFERR. 
  56.  
  57. Sample error trap program:  [saved on disk as ERRTRAP.  -jkh-] 
  58. ----------------- cut here ---------------------------------------------- 
  59. %%HP:T(3); 
  60. \<< 0 \-> et 
  61.   \<< { IFERR 1 50 
  62.              FOR j 
  63.               "YOUR CLEANUP PROC." 1 DISP  
  64.               "#" j \->STR + " HERE" + 2 DISP 
  65.              NEXT  
  66.         THEN et EVAL 
  67.         ELSE DONE 
  68.         END } OBJ\-> DROP 
  69.     'et' STO  
  70.     IFERR 1 1000 
  71.       FOR j 
  72.         "YOUR MAIN PROC." 1 DISP 
  73.         "#" j \->STR " NOW" + + 2 DISP 
  74.       NEXT 
  75.     THEN et EVAL 
  76.     END 
  77.   \>> 
  78. \>> 
  79. ----------------- cut here ---------------------------------------------- 
  80.  
  81. (Comp.sys.handhelds) 
  82. Item: 2012 by _macrokid at hpcvbbs.UUCP 
  83. Author: [Kevin Vashi] 
  84.   Subj: IFERR bug. 
  85.   Date: Mon Feb 11 1991 14:48  
  86.  
  87. Hello, 
  88.  
  89.        I belive there is an bug in the IFERR library that was posted by Mr. 
  90. Wickes few days ago.  If you put the sample program on level 1 and execute 
  91. X_TIME (Timing routine from Mr. Donnely's Toolkit) and if you press ENTER 
  92. <ATTN> while it's running and then wait until it's done then the calculator 
  93. performs a system halt.  If anybody has any insights about this then please 
  94. post it. 
  95.  
  96. Thank You, 
  97. Kevin Vashi. 
  98.